import '@/styles/index.scss'
import 'highlight.js/styles/atom-one-dark.css'
import 'highlight.js/lib/common'

import hljsVuePlugin from '@highlightjs/vue-plugin'
import type { App } from 'vue'

import AppIcon from '@/components/application/src/AppIcon.vue'

import pkg from '../package.json'
import { setupComponents } from './components/setup'
import { setupDirectives } from './directives'
import router from './router'
import { setupStore } from './stores'
import { blankTime } from './utils'
import LoggerUtils from './utils/logger'
const isDev = import.meta.env.DEV

async function bootstrap(app: App) {
  // 状态管理
  setupStore(app)

  app.use(hljsVuePlugin)
  // 注册路由
  app.use(router)
  // 注册全局指令
  setupDirectives(app)

  if (isDev) {
    const ElementPlus = await import('element-plus')
    app.use(ElementPlus.default)
  }

  // 注册全局组件
  setupComponents(app)

  // 挂载
  app.mount('#app')

  app.component('AppIcon', AppIcon)
  LoggerUtils.version(
    `\CERT SYSTEM For Web \n\nversion: ${pkg.version}\nenv: ${
      import.meta.env.MODE
    }\nBlank Time: ${blankTime()}\n`
  )
}
export default bootstrap
